#region Summary

// 
// Owner : JackieHan 
// 
// Solution : LearnSolution 
// 
// Project : JackieHan.NHibernate3.Repository
// 
// File : NormalInitializeNHConfiguration.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 一般设置NHConfiguration的Domain Mapping
// 
// History : 
//			2010-09-15 00:46:43	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using NHibernate;
using NHibernate.Cfg;

#endregion

namespace JackieHan.NHibernate3.Repository
{
    /// <summary> 
    /// 一般设置NHConfiguration的Domain Mapping
    /// </summary>
    public class NormalInitializeNHConfiguration:IInitializeNHConfiguration
    {

        #region IInitializeNHConfiguration Members

        public ISessionFactory Initialize()
        {
            Configuration cfg = LambdaConfiguration.CompletedConfig();
            string folder = AppDomain.CurrentDomain.BaseDirectory;
            string assemblyName = "JackieHan.NHibernate3.Domain.dll";
            string path = Path.Combine(folder, assemblyName);
            Assembly assembly = Assembly.LoadFile(path);
            cfg.AddAssembly(assembly);
            return cfg.BuildSessionFactory();
        }

        #endregion
    }
}